@extends('layouts.admin.header')
@section('cnt')
<div class="layui-fluid">
    <div class="layui-row">

        <form class="layui-form">
            @csrf
            <div class="layui-form-item">
                <label for="name" class="layui-form-label">
                    <span class="x-red">*</span>规格名称
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="name" name="name" required="" lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>规格名称
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">属性</label>
                <div class="layui-input-block">
                    <textarea name="list" placeholder="请输入内容，用英文逗号隔开 如红色,黑色" class="layui-textarea"></textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                </label>
                <button  class="layui-btn" lay-filter="add" lay-submit="">
                    增加
                </button>
            </div>
        </form>

    </div>
</div>
@endsection
@section('js')
    <script type="text/javascript" src="{{asset('admin/js/jquery.min.js')}}"></script>

    <script>
    layui.use(['form', 'layer','upload'],
        function() {
            var   $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;

            //监听提交
            form.on('submit(add)', function(data) {
                let url='{{route('admin.goodsattrs.store')}}';
                let formData = data.field;
                $.post(url,formData).then(({status,msg})=>{
                    if(status==200){
                        //发异步，把数据提交给php
                        layer.alert("增加成功", {
                                icon: 6
                            },
                            function() {
                                //关闭当前frame
                                xadmin.close();
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                    }else{
                        layer.alert("增加失败", {
                                icon: 5
                            },
                            function() {
                                //关闭当前frame
                                xadmin.close();
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                    }
                });
                return false;
                    });


        });
</script>
@endsection
